#include"comm.hpp"

int main()
{
  //生成key
  key_t key = GetKey();
  
  //生成共享内存
  int shmid = CreatShm(key,gsize);
  printf("shmid: %d\n", shmid);
  
  toHex(key);

  //关联
  char* Start = AttachShm(shmid);
  printf("%p\n", Start);

  //通信
  int n = 35;
  while(n--)
  {
    cout << "client send message to me : " << Start << endl;
    sleep(1);
  }

  //去关联
  DetachAttach(Start);

  //删除共享内存
  DeleteShm(shmid);

  return 0;
}
